<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * date: 2021-09-09 21:04:35
 * @LastEditors: Sam
 * @LastEditTime: 2022-06-17 10:55:59
 */


namespace app\admin\controller;
use app\admin\model\{User as UserModel,Sign as SignModel,SignLog};
use app\common\BaseController;

/**
 * 签到
 * @author Sam
 * date 2021-09-09
 */
class Sign extends BaseController
{

    /**
     * 签到列表
     * date 2020/8/15 14:09
     */
    public function sign_list() {
        $page   = (int)request()->param('page', 0);
        $limit  = (int)request()->param('limit', 10);
        $search = request()->param();
        $where = [];
        if(isset($search['user']) && $search['user'] !=''){
            $uid = UserModel::where('nickname','like',"%{$search['user']}%")->column('id');
             $where[] = ['id','in',$uid];
        }
        $query  = SignLog::with('user')->where($where)->order('id desc');
        $total  = $query->count();
        $data   = $query->page($page, $limit)->order('id desc')->select();
 
        return $this->success('', [
            'start' => $page,
            'limit' => $limit,
            'data'  => $data,
            'total' => $total,
        ]);
    }
}
